#define DEBUG
#include <cstdio>

using namespace std;

const int maxn=2000, maxm=2000, mods=998244353;

int main() {
  freopen("temple.in", "r", stdin);
  freopen("temple.out", "w", stdout);

  static long long f[maxm+1][maxn+1], ans[maxm+1][maxn+1];

  f[0][0] = 1;
  for (int i=0; i<=maxn; i++) {
    ans[0][i] = 1;
  }
  for (int i=1; i<=maxm; i++) {
    for (int j=1; j<=maxn; j++) {
      if (i%2==j%2) {
	f[i][j] = (f[i][j]+ans[i-1][j-1])%mods;
      }
      ans[i][j] = (ans[i][j-1]+f[i][j])%mods;
    }
  }

  int t;
  scanf("%d", &t);
  for (int i=1; i<=t; i++) {
    int n, m;
    scanf("%d %d", &n, &m);
    printf("%lld\n", ans[m][n]);
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
